Repository navigation
Conversation
The pager was written for Textual 0.1 (ScrollView, App.run() as a class method, view.dock()), so rich-cli pinned textual <0.2 and, through it, rich <13. Those pins make rich-cli impossible to install next to anything that uses a current Rich or Textual. Rewrite PagerApp on top of ScrollableContainer and a Static holding the pre-rendered lines. The existing keys are kept as bindings (q to quit, j/k for one line, space for a page, ctrl+d/ctrl+u for half a page), and the container adds the arrow, page up/down, home and end keys. Require textual >= 1.0.0 and rich >= 13.3.3 (the minimum Rich of Textual 1.0).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rich-cli pins
textual (>=0.1.18,<0.2.0)becausepager.pyuses the Textual 0.1 API (textual.widgets.ScrollView,App.run()as a class method,view.dock()), and textual 0.1 in turn holds rich-cli torich <13. With those pins rich-cli cannot be installed next to anything that uses a current Rich or Textual (#75, #128), and distributions that ship one Textual (e.g. 8.x) cannot use the--pagermode at all:from textual.widgets import ScrollViewraisesImportError.This rewrites
PagerAppon the current API:PagerViewis a focusableScrollableContainerholding aStaticwith the pre-renderedPagerRenderable(unchanged).qquits,j/kscroll one line,spacepages down,ctrl+d/ctrl+uscroll half a page; the container adds arrows, page up/down, home and end.__main__.pynow doesPagerApp(content=..., title=resource).run().textual (>=1.0.0),rich (>=13.3.3)(Textual 1.0's minimum). CHANGELOG updated.poetry.lockis not regenerated in this PR; it needs apoetry lockafter merging (or I can add it if you prefer).Testing
Headless test with
App.run_test()(80x24) on a 300-lineSyntaxrender: checks the view gets focus, then pressesj j j k space ctrl+d ctrl+u end homeand checksscroll_yafter each (1, 2, 3, 2, 25, 37, 25, max, 0), thenq.Also on 3.12/3.13/3.14 with rich 15.0.0:
pytest tests(1 passed), andrich FILE --force-terminalfor README.md and every file intest_data/(csv, ipynb, rst), plusrich --print ... --export-svg, all without errors. The interactive pager itself was not driven in a real terminal.Context
Found while testing packages against Python 3.13 for FreeBSD ports (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292105).